﻿using System;
using System.Linq;

namespace UserRegistration
{
public static class PhoneUtils
{
    public static string FindAreaCode(string phone)
    {
        for (int i = 0; i < phone.Length; i++)
        {
            string prefix = phone.Substring(0, i);
            if (IsAreaCode(prefix))
            {
                return prefix;
            }
        }
        return null;
    }

    public static bool IsAreaCode(string prefix)
    {
        string[] areas = new string[] { "0571", "021", "010" };
        return areas.Contains(prefix);
    }
}
}